<div style="width:350px; text-align:left">
    <php>if(isset($has_status)){</php>
    <php>$status_class = $is_success_status ? 'ico_cue_ok' : 'ico_cue_no';</php>
	<div class="iine_warning"  style="padding:10px; margin:10px;"><span class="{$status_class} alM mr5" style="margin-top:0"></span>{$status_title}</div>
	<php>}</php>
    <div  style="padding:10px"><span class="right lh20" id="_widget_weibo_words_count" style="color:#008800">还可以输入140个汉字</span></div>
    <div style="padding:0 10px">
        <textarea id="_widget_weibo_content" name="content" style="font-family: Tahoma,宋体; overflow: hidden; border: 1px solid #ccc; background-color:#F8F8F8; word-wrap: break-word; font-size: 12px; line-height: 18px; height: 65px; width:328px;">{$content}</textarea>
    </div>
    <div class="answers">
      <php>if($type==1){
      	if(file_exists('./data/uploads/'.$type_data)){
      </php>
      	<img src="__ROOT__/thumb.php?w=32&h=32&t=f&url=./data/uploads/{$type_data}" />
      <php>}elseif(file_exists($type_data)){</php>
     	<img src="__ROOT__/thumb.php?w=32&h=32&t=f&url={$type_data}" />
      <php>}}</php>
   	<input type="button" onclick="_widget_weibo_do_post()" id="_widget_weibo_post_button" class="btn_b" value="{$button_title}"></div>
</div>

<script>
$(document).ready(function(){
	$("#_widget_weibo_content").keyup(function(event){
		// 32:空格 8:退格 13:回车 17:Ctrl
        if(event.keyCode==32 || event.keyCode==8 || event.keyCode==13 || event.keyCode==17){
        	_widget_weibo_check_words_count(this,140);
        }
    }).keypress(function(){
    	_widget_weibo_check_words_count(this,140);
    }).blur(function(){
    	_widget_weibo_check_words_count(this,140);
    //}).keydown(function(){
    //  checkInputLength(this,140);
    //}).keyup(function(){
    //  checkInputLength(this,140);
    });
	
	_widget_weibo_check_words_count($("#_widget_weibo_content"),140);
    document.getElementById('_widget_weibo_content').focus();
    shortcut('ctrl+return', function(){_widget_weibo_do_post();},{'target':'_widget_weibo_content'});
});

function _widget_weibo_do_post() {
	var content = $('#_widget_weibo_content').val();
	var type = '{$type}';
	var typedata = '{$type_data}';
	$.post(U('home/Widget/doPostWeibo'),{content:content,type:type,typedata:typedata},function(res){
		if(res=='1'){
			ui.box.close();
			ui.success('发布成功');
		}else {
			ui.error('发布失败');
		}
	});
}

function _widget_weibo_check_words_count(obj,num) {
	var len = $(obj).val().length;
	var post_button_obj = $('#_widget_weibo_post_button');
	var word_count_obj  = $('#_widget_weibo_words_count');
	
    if(len==0){
        post_button_obj.attr('disabled',true).attr('class','btn_b_disable');
        word_count_obj.html('你还可以输入'+ (num-len) + '字');
    }else if( len > num ){
        post_button_obj.attr('disabled',true).attr('class','btn_b_disable');
        word_count_obj.css('color','red').html('已超出'+ (len-num) +'字');
    }else if( len <= num ){
        post_button_obj.removeAttr('disabled').attr('class','btn_b');
        word_count_obj.css('color','#008800').html('你还可以输入'+ (num-len) + '字');
    }
}
</script>